from sklearn.preprocessing import OneHotEncoder
import numpy as np

x=np.random.randint(0,3,(8,1))
print(x)

oh=OneHotEncoder()
x_onehot=oh.fit_transform(x).toarray()
print(x_onehot)